package edu.xidian.sselab.cloudcourse.domain;

import lombok.Data;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;

import java.util.List;

@Data
public class test8_entity implements Comparable<test8_entity>{

    String nation; //车系，德系，法系，韩系，日系，美系，自主
    Integer salenumber; //销售数量

    public test8_entity map(Result result) { //将查询hbase的查询结果映射为test8_entity类
        setNation(Bytes.toString(result.getRow()));
        List<Cell> cellList = result.listCells();
        Cell cell = cellList.get(0);
        String value = Bytes.toString(CellUtil.cloneValue(cell));
        setSalenumber(Integer.parseInt(value));
        return this;
    }

    @Override
    public int compareTo(test8_entity t8){
        return this.salenumber.compareTo(t8.salenumber);
    }
}
